package sun.superstring.constructor;

public class Test {
    public static void main(String[] args) {
        // 目标：认识类的构造器，搞清楚其特点和常见应用场景
        // 构造器的特点：创建对象时，对象会立即自动调用构造器
        Student s1 = new Student(); // 创建一个学生对象，同时会自动调用那个无参构造器
        Student s2 = new Student("西门吹雪"); // 创建一个学生对象，同时会自动调用那个匹配参数的构造器

        System.out.println("=================");
        Student t1 = new Student();
        t1.name = "孙悟空";
        t1.age = 18;
        t1.sex = '男';
        System.out.println(t1.name);
        System.out.println(t1.age);
        System.out.println(t1.sex);

        Student t2 = new Student("猪八戒", 18, '男');
        System.out.println(t2.name + "\t" + t2.age + "\t" + t2.sex);
    }
}
